package com.hm.cms.task;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.task.TaskExecutor;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.hm.cms.websit.JinseCaiJinHandler;
import com.hm.cms.websit.JinseCaiJinHandler2;
import com.hm.common.util.DateUtil;

import lombok.extern.slf4j.Slf4j;

/**
 * @author shishun.wang
 * @date 2017年12月1日 下午3:52:42
 * @version 1.0
 * @describe 连续任务
 */
@Slf4j
@Component
public class ContinuousTask {

	@Autowired
	private TaskExecutor taskExecutor;

	@Autowired
	private JinseCaiJinHandler jinseCaiJinHandler;
	
	@Autowired
	private JinseCaiJinHandler2 jinseCaiJinHandler2;

	/**
	 * 每隔一小时执行一次
	 */
	@Scheduled(cron = "0 */60 * * * *")
	public void handler() {
		log.info(DateUtil.now4yyyyMMddhhmm() + "执行金色财经数据抓取");
		taskExecutor.execute(new Runnable() {

			@Override
			public void run() {
				jinseCaiJinHandler.handler();
				jinseCaiJinHandler2.handler();
			}
		});
	}
}
